package com.bungarus.sdk;

import com.bungarus.codec.protobuf.MessageProtobuf;

/**
 * Created by tang on 2018/11/11.
 */
public class MessageBuilder {
    private static final SnowflakeIdMaker idMaker = new SnowflakeIdMaker(31, 31);
    public static MessageProtobuf.Message buildAckMessage(String messageId) {
        MessageProtobuf.Header header = MessageProtobuf.Header.newBuilder()
                .setId(messageId)
                .setType(MessageType.ACK)
                .build();

        MessageProtobuf.Message message = MessageProtobuf.Message.newBuilder()
                .setHeader(header)
                .build();
        return message;
    }

    public static MessageProtobuf.Message buildHeartbeatPingMessage() {
        MessageProtobuf.Header header = MessageProtobuf.Header.newBuilder()
                .setId(String.valueOf(MessageBuilder.idMaker.nextId()))
                .setType(MessageType.HEARTBEAT_PING)
                .build();
        MessageProtobuf.Message heartbeatPing = MessageProtobuf.Message.newBuilder()
                .setHeader(header)
                .build();

        return heartbeatPing;
    }
}
